<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="../js/vue-2.6.12.js"></script>
  <script src="../js/vue-router.js"></script>
</head>
<body>
  <div id="app">
    <router-link to="/login">登录</router-link>
    <router-link to="/register">注册</router-link>
    <br>
    <router-view></router-view>
  </div>
  <template id="login-form">
    <div>
      <router-link to="/login/phone">手机验证码登录</router-link>
      <router-link to="/login/account">账号密码登录</router-link>
      <br>
      <router-view></router-view>
    </div>
  </template>
  <template id="register-form">
    <form action="">
      用户名: <input type="text" name="username" > <br>
      密码: <input type="password" name="pwd1"> <br>
      确认密码: <input type="password" name="pwd2" > <br>
      <input type="submit" value="注册">
    </form>
  </template>
  <template id="phone-login-form">
    <form action="">
        手机号: <input type="number" name="phone" > <br>
        验证码: <input type="password" name="code"> <br>
        <input type="submit" value="登录">
    </form>
  </template>
  <template id="account-login-form">
      <form action="">
          用户名: <input type="text" name="username" > <br>
          密码: <input type="password" name="pwd"> <br>
          <input type="submit" value="登录">
      </form>
  </template>
  <script>
    const loginForm = {
      template:"#login-form"
    }
    const registerForm = {
      template:"#register-form"
    }
    const phoneForm = {
      template:"#phone-login-form"
    }
    const accountForm = {
      template:"#account-login-form"
    }
    var router = new VueRouter({
      routes:[
        {
          name:"login",
          path:"/login",
          component:loginForm,
          children:[
            {path:"phone",component:phoneForm},
            {path:"account",component:accountForm}
          ]
        },
        {name:"register",path:"/register",component:registerForm},
        {name:"default",path:"/",redirect:"/login"},
      ]
    });
    new Vue({
      el:"#app",
      router:router
    });
  </script>
</body>
</html>